package com.gtw.modules.api.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.gtw.modules.api.service.TbCollectionService;
import com.gtw.modules.dao.TbCollectionDao;
import com.gtw.modules.entity.TbCollection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/** 用户收藏接口实现类
 * Created by wuye on 2018/2/1.
 */
@Service
public class TbCollectionServiceImpl implements TbCollectionService {

    @Autowired
    private TbCollectionDao tbCollectionDao;


    @Override
    public TbCollection queryObject(Integer id) {
        return tbCollectionDao.queryObject(id);
    }

    @Override
    public TbCollection queryByCommodity(String uid, Integer commodityid) {
        return tbCollectionDao.queryByCommodity(uid, commodityid);
    }

    @Override
    public Page<TbCollection> queryPageList(Page<TbCollection> pageUtil, Map<String, Object> map) {
        pageUtil.setRecords(tbCollectionDao.queryPageList(pageUtil, map));
        return pageUtil;
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public TbCollection save(TbCollection tbOrder) {
        tbCollectionDao.insert(tbOrder);
        return tbOrder;
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public void update(TbCollection tbOrder) {
        tbCollectionDao.update(tbOrder);
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public void deleteBatch(Integer[] id) {
        for(int i =0;i<id.length;i++) {
            tbCollectionDao.deleteByPrimaryKey(id[i]);
        }
    }
}
